home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Adobe Graphics & Publishing SDK 1996 December
/
Adobe Graphics & Publishing SDK 1996 December.iso
/
mac
/
PageMaker 6.5 SDK Mac
/
SourceCode
/
PageMakerClassLibrary
/
LowLevel
/
PReplyBuf.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-05
|
2KB
|
108 lines
/*
*--- PReplyBuf.cpp -------------------------------------------------------
* Copyright (c) 1995-96 Adobe Systems Incorporated. All rights reserved.
* Created on Thu, Oct 19, 1995 @ 8:18 PM by Paul Ferguson.
*
* Description: For notes about this class, refer to the
* header file: PReplyBuf.h
*-------------------------------------------------------------------------
*/
#include "string.h"
#include "PReplyBuf.h"
PReplyBuf::PReplyBuf(const char * ch)
{
bufStart = curCh = ch;
}
PReplyBuf& PReplyBuf::operator>> (const char ** aStringRef) // Just set char * and scan over the string.
{
*aStringRef = (char *) curCh;
register char * ch = (char *) curCh;
while (*ch++)
;
if (long(ch) & 0x01) ++ch;
curCh = ch;
return *this;
}
PReplyBuf& PReplyBuf::operator>> (char * aString) // Copy the string.
{
register char * dest = aString;
register const char * src = curCh;
while (*dest++ = *src++)
;
if (long(src) & 0x01) ++src;
curCh = src;
return *this;
}
// This function copies and translates from C to Pascal string.
// It will only copy a maximum of 255 characters, but will scan
// to the end of the source string regardless of
PReplyBuf& PReplyBuf::operator>> (unsigned char * aString) // Copy the Pascal string.
{
register unsigned char * dest = aString;
unsigned char * byte0 = aString;
register const unsigned char * src = (const unsigned char *) curCh;
register size_t numChars = 0;
dest++; // Reserve room for the length byte
while (*src) // Copy string, but don't copy null byte.
{
*dest++ = *src++;
numChars++;
}
src++; // need to skip null byte;
if (long(src) & 0x01) ++src;
if (numChars > 255) numChars = 255;
*byte0 = (unsigned char) numChars;
curCh = (const char *) src;
return *this;
}
PReplyBuf& PReplyBuf::operator>> (short& aShort)
{
aShort = *(short *) curCh;
curCh += sizeof(short);
return *this;
}
PReplyBuf& PReplyBuf::operator>> (unsigned short& aShort)
{
aShort = *(unsigned short *) curCh;
curCh += sizeof(unsigned short);
return *this;
}
PReplyBuf& PReplyBuf::operator>> (long& aLong)
{
aLong = *(long *) curCh;
curCh += sizeof(long);
return *this;
}
PReplyBuf& PReplyBuf::operator>> (unsigned long& aLong)
{
aLong = *(long *) curCh;
curCh += sizeof(unsigned long);
return *this;
}
// end of PReplyBuf.cpp